<template>
  <div class="navbar">
    <el-menu
      :default-active="$route.path"
      class="el-menu-vertical-demo"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
    >
      <el-menu-item
        :index="item.path"
        v-for="item in navList"
        :key="item.id"
        @click="goto(item.path)"
      >
        <i :class="item.icon"></i>
        <span slot="title">{{ item.name }}</span>
      </el-menu-item>
      <!-- <el-menu-item index="2">
        <i class="el-icon-menu"></i>
        <span slot="title">导航二</span>
      </el-menu-item>
      <el-menu-item index="3">
        <i class="el-icon-menu"></i>
        <span slot="title">导航二</span>
      </el-menu-item>
      <el-menu-item index="4">
        <i class="el-icon-menu"></i>
        <span slot="title">导航二</span>
      </el-menu-item>-->
    </el-menu>
  </div>
</template>

<script>
export default {
  data() {
    return {
      navList: [
        {
          id: 1,
          name: "用户管理",
          path: "/box/users",
          icon: "el-icon-user"
        },
        {
          id: 2,
          name: "商品管理",
          path: "/box/goods",
          icon: "el-icon-goods"
        },
        {
          id: 3,
          name: "订单管理",
          path: "/box/orders",
          icon: "el-icon-s-order"
        },
        {
          id: 4,
          name: "评论管理",
          path: "/box/comments",
          icon: "el-icon-s-management"
        }
      ]
    };
  },

  components: {},

  methods: {
    goto(path) {
      this.$router.push(path); //实现点击跳转
    }
  }
};
</script>

<style scoped>
/* 左侧导航栏 */
.navbar {
  position: absolute;
  width: 230px;
  top: 50px;
  left: 0px;
  bottom: 0px;
  overflow-y: auto;
  background-color: #545c64;
}
</style>